package cn.sofwin.day0122.homework.Account;

/**
 * 该类包括的属性：账号id，余额balance，年利率annualInterestRate；
 * 包含的方法：带参构造方法，访问器方法（getter和setter方法），
 * 取款方法withdraw()，存款方法deposit()
 * @author 啊剥了菠萝没有菠萝蜜
 */
public class Account {
    private int id;
    private double balance;
    private double annualInterestRate;

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    // 取款
    public void withDraw(double amount){
        if (this.balance < amount){
            System.out.println("余额不足，取款失败");
        }else {
            this.balance -= amount;
            System.out.println("成功取出：" + amount);
        }
    }

    // 存款
    public void deposit(double amount){
        this.balance += amount;
        System.out.println("成功存入：" + amount);
    }
}
